import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

async function main() {
  console.log(`Start seeding ...`);

  const rootUser = await prisma.user.upsert({
    where: { email: "yangjs1998@gmail.com" }, // Use a unique field for lookup
    update: {},
    create: {
      username: "root",
      email: "yangjs1998@gmail.com",
      role: "admin",
    },
  });

  console.log(`Created root user: ${rootUser.username} (${rootUser.email})`);

  console.log(`Seeding finished.`);
}

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });
